package cn.thinkluck.pattern.visitor.computer;

import cn.thinkluck.pattern.visitor.visitor.ComputerVisitor;

import java.util.ArrayList;
import java.util.List;

/**
 * 电脑实现类
 *
 * @Author liutao
 * @DateTime 2024/8/4 下午2:42
 */
public class ComputerImpl implements Computer {

    /**
     * 电脑组件·列表
     */
    private List<Computer> computerList = new ArrayList<>();

    public ComputerImpl() {
        computerList.add(new KeyboardImpl());
        computerList.add(new MouseImpl());
    }

    /**
     * 电脑的行为
     *
     * @param computerVisitor 电脑访问者
     */
    @Override
    public void accept(ComputerVisitor computerVisitor) {
        for (Computer computer : computerList) {
            computer.accept(computerVisitor);
        }
    }
}
